home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / util / libs / amrtl881.lha / README.AMIGA < prev   
Encoding:
Text File  |  1998-09-20  |  12.7 KB  |  342 lines

  1.  
  2.                              AmigaMesaRTL 2.0
  3.                       A run-time library of Mesa 2.6
  4.  
  5.                          by Jarno van der Linden
  6.                             jarno@kcbbs.gen.nz
  7.  
  8.             http://www.kcbbs.gen.nz/~jarno/AmigaMesaRTL.html
  9.  
  10.              Mesa 2.6 is Copyright (C) 1995-1998  Brian Paul
  11.  
  12.  
  13.  
  14. INTRODUCTION
  15. ============
  16.  
  17. Once upon a time there was an Amiga port of Mesa by Stefan Zivkovic.
  18. However, just as this port became interesting, Stefan could no longer
  19. support it.
  20.  
  21. Then came CyberGL. A run-time library, which ran reasonably comfortably
  22. even on lower-end machines with AGA. Unfortunately, it only implemented a
  23. subset of OpenGL. Furthermore, the output even on a 256 colour AGA screen
  24. was far from impressive. At present, development seems to have stalled
  25. (possibly pending the release of the 3D drivers for the CV-PPC and BVision
  26. cards).
  27.  
  28. Back to Mesa, through H&P we've seen the release of StormMesa.
  29. Unfortunately this too comes in the form of a link library. (Although that
  30. is soon to change I gather).
  31.  
  32. So I set out to create my own driver with the following objectives:
  33.  
  34.     - Based on the latest release of Mesa
  35.     - Should come in the form of a run-time library
  36.     - Reasonable speed on an 50MHz '030/'881 system
  37.     - Good quality output on AGA
  38.  
  39. With AmigaMesaRTL, I think I have achieved these goals. Of course, don't
  40. expect miracles. Framerates are still better counted in seconds-per-frame
  41. rather than frames-per-second on my machine (A1200, Blizzard1230IV, 50MHz
  42. '030/'881, 32MB fast). But it is still faster than CyberGL and the output
  43. is a significantly better.
  44.  
  45.  
  46.  
  47. THEORY OF OPERATION
  48. ===================
  49.  
  50. The main Mesa functions (such as glBegin(), glFlush(), etc. etc. etc.) are
  51. in mesamain.library. These functions do all sorts of things, and
  52. eventually call some driver functions to handle the platform-specific
  53. output.
  54.  
  55. The driver (amigamesertl.c) does all reading from and writing to a simple
  56. memory buffer. This buffer is made up out of single bytes in the case of
  57. colour index mode, and 4 bytes in the case RGB or RGBA mode.
  58.  
  59. When glFlush() is called, the buffer is processed by an Output Handler.
  60. The traditional thing for an output handler to do is to quantize the
  61. buffer to a displayable number of colours, and C2P the buffer to a window.
  62. Output handlers can however do many other things, such as send the buffer
  63. directly to an image editing program (e.g. ImageFX using the
  64. magic.library).
  65.  
  66. What output handler to use depends on the output type specified by the
  67. application. For example, if the output type is "Window", the output
  68. handler specified by the environment variable "AmigaMesaRTL/Window" is
  69. used.
  70.  
  71. The default output handler is a slightly modified version of DL1 from a
  72. package by Dennis Lee (denlee@ecf.utoronto.ca). I've included the original
  73. documentation in the amiga/outputhandlers/dl1 directory.
  74.  
  75. Because of the various buffers involved, AmigaMesaRTL does use a fair bit
  76. of memory.
  77.  
  78.  
  79.  
  80. COMPILING THE LIBRARY
  81. =====================
  82.  
  83. The AmigaMesaRTL distribution only contains the changed and new files of
  84. Mesa. You will need the Mesa 2.6 distribution. Once you have obtained the
  85. Mesa 2.6 distribution and unpacked it to somewhere, copy the amiga
  86. directory of AmigaMesaRTL to the Mesa directory. Go to the amiga/src
  87. directory, change the SCOPTIONS file to suit your system (mainly the MATH
  88. and CPU settings), and run SMake. Sit back, relax, enjoy life. This is
  89. going to take a while.
  90.  
  91. Note that there are still a few references to __XCEXIT(). Just ignore it
  92. and let the linker replace it with __stub().
  93.  
  94. Once this is done, you should end up with a file called mesamain.library
  95. in the amiga/library directory.
  96.  
  97. Go to the amiga/drivers/amigamesartl directory, edit SCOPTIONS, run SMake.
  98. Out pops amiga/mesadrivers/amigamesartl (no ".library").
  99.  
  100. Some output handlers can be found in amiga/outputhandlers. Go to one of
  101. them (e.g. dl1), edit SCOPTIONS, run SMake, and you should now have a
  102. library called amiga/library/outputhandlers/dl1.
  103.  
  104. The GLUT library is made by going to amiga/src-glut, edit SCOPTIONS,
  105. SMake, and you have amiga/library/glut.library.
  106.  
  107. Finally, go to the amiga/lib directory, edit the SCOPTIONS file if you
  108. want to, run SMake. Out should come Mesa.LIB and GLUT.LIB.
  109.  
  110. That is all that is needed to get a working mesa library. Whew!
  111. Alternatively, edit all the SCOPTIONS files you can find to suit your
  112. system and execute mklib.amiga.
  113.  
  114.  
  115.  
  116. USING THE LIBRARY
  117. =================
  118.  
  119. To compile a program using AmigaMesaRTL, make sure the compiler can see
  120. the files in amiga/include and the link libraries in amiga/lib (by e.g.
  121. adding them to your INCLUDE: tree).
  122.  
  123. Mesa.LIB contains autoopen code for the mesamain.library, so you shouldn't
  124. have to worry about opening and closing it. Just don't forget to link with
  125. Mesa.LIB. It will also cause a driver library to open.
  126.  
  127. If you want to open the libraries yourself, I recommend opening
  128. mesamain.library, and then getting a driver library base from it by
  129. calling mesaGetAttr(MESA_DriverBase,&mesadriverBase). It is also possible
  130. to open a specific driver, see the mesadriver and mesamain docs.
  131.  
  132. In typical use, you probably want to output the result to a window. After
  133. setting up your Intuition window as per usual, create a context for it by
  134. calling AmigaMesaRTLCreateContext(). Pass a pointer to the window to the
  135. output handler with OH_Output, and tell it is a window by setting
  136. OH_OutputType to "Window". Make sure the context is current by calling
  137. AmigaMesaRTLMakeCurrent().
  138.  
  139. Do lots of interesting graphics stuff. Don't forget that glFlush() has to
  140. be called (directly or indirectly) for the result to be send to an output
  141. handler.
  142.  
  143. Before closing the window, you should destroy the context with
  144. AmigaMesaRTLDestroyContext().
  145.  
  146. For example (without error checking):
  147.  
  148.   my_window = OpenWindowTags(...);
  149.   my_context = AmigaMesaRTLCreateContext(
  150.                      OH_OutputType,  "Window,    /* Output is a window */
  151.                      OH_Output,      my_window,  /* Use my window */
  152.                      AMRTL_RGBAMode, TRUE,       /* RGBA drawing mode */
  153.                      TAG_END);
  154.   AmigaMesaRTLMakeCurrent(my_context);
  155.  
  156.   /* ...Do OpenGL stuff... */
  157.  
  158.   AmigaMesaRTLDestroyContext(my_context);
  159.   CloseWindow(my_window);
  160.  
  161. See the included examples and src-glut/glutCreateWindow.c for inspiration,
  162. and the mesadriver and outputhandler docs.
  163.  
  164.  
  165.  
  166. GLUT
  167. ====
  168.  
  169. Having a Mesa library is all fine and dandy, but most Mesa and OpenGL
  170. examples use the GL Utility Toolkit (GLUT) by Mark Kilgard. So the obvious
  171. answer is: we need a port of GLUT.
  172.  
  173. Having looked at the GLUT source code, this is easier said than done. It
  174. is highly X11-centric, with a Windows port mixed in. I thought about it,
  175. but in the end I decided to do a from-scratch GLUT look-alike
  176. implementation. It can be found in amiga/src-glut.
  177.  
  178. At present, most of the most-commonly used functions are implemented. No
  179. guarantee that they behave identically to the official GLUT distribution,
  180. but most of the redbook examples seem to work OK.
  181.  
  182.  
  183. Using GLUT
  184. ----------
  185.  
  186. when compiling a GLUT program, make sure you link with GLUT.LIB and
  187. Mesa.LIB. These will open the libraries for you. If you want to open the
  188. GLUT library yourself, you must remember to tell GLUT which mesamain base
  189. and mesadriver base to use by calling glutAssociateGL(). These bases
  190. should be the same ones the application is using.
  191.  
  192. When run, a glut program will by default let the output handler open a
  193. window. If told top open a window itself, GLUT will try to open a window
  194. on a public screen named Mesa, or the one specified by the pubscreen
  195. argument. Use one of the zillion pubscreen managers available on AmiNet to
  196. set up a public screen.
  197.  
  198. GLUT Menus
  199. ..........
  200. The GLUT menus use the usual Amiga menu system. Instead of having a menu
  201. associated with a mouse button, there is a "Left Menu", "Middle Menu", and
  202. "Right Menu" menu.
  203. As the Amiga menu system only supports up to one level of sub-menus, any
  204. sub-sub-menus (and sub-sub-sub-menus and sub-sub-sub-sub-menus and ...)
  205. will be changed to a sub-menu after the parent.
  206.  
  207. GLUT mouse buttons
  208. ..................
  209. As the right mouse button is tied up with menus, middle and right mouse
  210. button presses can be done by qualifying the left mouse button press with
  211. the Right-Amiga and Right-Alt keys respectively. For those of you with
  212. three-button mice, the middle button should also be recognised.
  213.  
  214. GLUT termination
  215. ................
  216. The GLUT main loop is traditionally terminated by exit()'ing the program.
  217. Amiga GLUT uses SAS/C's STI_ and STD_ mechanism to clean up on exit().
  218. Quiting a GLUT program is usually done by pressing the ESC key. Clicking
  219. the window close button will cause Amiga GLUT to call the context's
  220. keyboard function with an ESC key code.
  221. However, some example programs never exit. Instead they expect the user to
  222. kill the program (by e.g. ^C). To handle such evil programs, Amiga GLUT
  223. has a panic drop-through. If pressing the window close button has no
  224. effect (i.e. the program is not listening to ESC key presses), a second
  225. click on the window close button will cause glutMainLoop() to return. This
  226. usually works as glutMainLoop() is often the last command in main() before
  227. it returns. But, as this is against the documented behaviour of
  228. glutMainLoop(), Bad Things may happen instead.
  229. As of version 2, the GLUT library also listens for ^C. When received, this
  230. too causes glutMainLoop() to return. This is handy in case the window
  231. doesn't have a close gadget.
  232.  
  233. GLUT keys
  234. .........
  235. The GLUT special keys implemented are: the cursor keys, and functon keys
  236. F1 to F10.
  237.  
  238. Idle
  239. ....
  240. A single glutMainLoop() loop will handle all the messages on the queue. If
  241. set, glutIdleFunc() will be called whenever glutMainLoop() finds no
  242. messages to handle (other than IDCMP_INTUITICKS) in a single loop. (This
  243. is in contrast to a macintosh implementation I know of which actually
  244. speeds up if you e.g. press a key).
  245.  
  246.  
  247. Running a GLUT program
  248. ----------------------
  249.  
  250. Any GLUT program which calls glutInit() (as all should), recognises the
  251. following command line options:
  252.  
  253.   Option      : -pubscreen
  254.   Values      : <any name>
  255.   Default     : Mesa
  256.   Description : Set the public screen to open windows on
  257.  
  258.   Option      : -outputhandler
  259.   Values      : <any name>
  260.   Default     : <not set>
  261.   Description : Set value for AMRTL_OutputHandler
  262.  
  263.   Option      : -outputhandlerversion
  264.   Values      : <any ULONG>
  265.   Default     : <not set>
  266.   Description : Set value for AMRTL_OutputHandlerVersion
  267.  
  268.   Option      : -nohandlerwindow
  269.   Values      : <none>
  270.   Default     : <not set>
  271.   Description : When specified, don't let the output handler open a
  272.                 window. GLUT will open a window instead.
  273.  
  274. If a program doesn't appear to give any output, check to see if it calls
  275. glFlush(), or anything that calls it (like glutSwapBuffers()). If it
  276. doesn't, add it (typically at the end of the display() function). Also
  277. make sure you give the program plenty of stack.
  278.  
  279.  
  280. WARNING!
  281. --------
  282.  
  283. Please beware that at present, Amiga GLUT lacks a lot of error checking.
  284. Bad Things will very likely happen if Something Goes Wrong.
  285.  
  286.  
  287.  
  288. ENVIRONMENT VARIABLES
  289. =====================
  290.  
  291. From v2, a variety of environment variables are used by AmigaMesaRTL. Here
  292. is a summary. The effect of a variable can be limited to one program by
  293. setting a local environment variable, or made general by setting it as a
  294. global environment variable. The values of each of these variables can of
  295. course be overridden by an application by setting tag values.
  296.  
  297.  
  298. AmigaMesaRTL/Driver        (default: amigamesartl)
  299. AmigaMesaRTL/DriverVersion (default: 2)
  300. --------------------------
  301. Name and version of driver to use. A driver with the exact name given is
  302. expected to be found in LIBS:MesaDrivers/.
  303.  
  304.  
  305. AmigaMesaRTL/OutputHandler        (default: dl1)
  306. AmigaMesaRTL/OutputHandlerVersion (default: 2)
  307. ---------------------------------
  308. Name and version of output handler to use. An output handler with the
  309. exact name given is expected to be found in LIBS:OutputHandlers/.
  310.  
  311.  
  312. AmigaMesaRTL/<output type> (e.g. AmigaMesaRTL/Window)
  313. --------------------------
  314. Name of the output handler to use for a specific output type. This
  315. overrides the AmigaMesaRTL/OutputHandler variable. An output handler with
  316. the exact name given is expected to be found in LIBS:OutputHandlers/.
  317.  
  318.  
  319. AmigaMesaRTL/<output handler>.prefs (e.g. AmigaMesaRTL/dl1.prefs)
  320. -----------------------------------
  321. Each output handler can have its own preferences. These are stored in this
  322. environment variable. The format is output handler specific, but should be
  323. parseable by ReadArgs() using the pattern obtained by getting the value of
  324. OH_ParameterQuery from the output handler.
  325.  
  326.  
  327.  
  328. MORE DOCUMENTATION
  329. ==================
  330.  
  331. Autodoc-style documentation is provided in amiga/drivers/mesadriver.doc,
  332. amiga/outputhandlers/outputhandler.doc, and amiga/src/mesamain.doc.
  333.  
  334.  
  335.  
  336. FUTURE
  337. ======
  338.  
  339. Mesa 3.0 will shortly emerge from beta state. It shouldn't take long for
  340. me update the library to it when it does.
  341.  
  342.